#include <QDebug>
#include "participant.h"


/*Participant::Participant(QObject *parent) :
    QObject(parent)
{
    name="Michael Rahr";
    pType=Organiser;
    pStatusType=ParticipantPresent;
}
*/
Participant::Participant(QObject *parent, QByteArray uid, QDateTime time) :
    QObject(parent),
    tagId(uid),
    scanTime(time),
    checkedIn(false)
{

}

Participant::Participant(QObject *parent, QByteArray uid, Participant::TagType participantType, QString participantName, Participant::StatusType participantStatus, QDateTime time) :
    QObject(parent),
    tagId(uid),
    tagType(participantType),
    name(participantName),
    status(participantStatus),
    scanTime(time),
    checkedIn(false)
{
    if(status == Participant::ParticipantPresent)
        checkedIn = true;
}

Participant::Participant(QString uid, QString participantType, QString participantName, QString participantStatus)
{
    qDebug() << uid;
    qDebug() << participantName;
    qDebug() << participantType;
    qDebug() << participantStatus;

    if(participantType == "Organiser")
        tagType = Participant::Organiser;
    else
        tagType = Participant::Paricipant;

    if(participantStatus == "Present")  {
        status = Participant::ParticipantPresent;
        checkedIn = true;
    }
    else if(participantStatus == "Absent")
        status = Participant::ParticipantAbsent;
    else if(participantStatus == "Unknown")
        status = Participant::ParticipantUnknown;
    name = participantName;
    tagId = uid.toAscii();
}


/*
Participant::~Participant()
{

}*/

void Participant::setData(Participant::TagType participantType, QString participantName, Participant::StatusType participantStatus)
{
    tagType = participantType;
    name = participantName;
    status = participantStatus;
    if(status == Participant::ParticipantPresent)
        checkedIn = true;
    emit dataUpdated();
}

void Participant::setData(QString participantType, QString participantName, QString participantStatus)
{
    if(participantType == "Organiser")
        tagType = Participant::Organiser;
    else
        tagType = Participant::Paricipant;
    if(participantStatus == "Present")  {
        status = Participant::ParticipantPresent;
        checkedIn = true;
    }
    else if(participantStatus == "Absent")
        status = Participant::ParticipantAbsent;
    else if(participantStatus == "Unknown")
        status = Participant::ParticipantUnknown;
    name = participantName;
    emit dataUpdated();
}

QByteArray Participant::getTagId()
{
    return tagId;
}

Participant::TagType Participant::getTagType()
{
    return tagType;
}

QString Participant::getName()
{
    return name;
}

Participant::StatusType Participant::getStatus()
{
    return status;
}

QDateTime Participant::getScanTime()
{
    return scanTime;
}

bool Participant::getCheckedIn()
{
    return checkedIn;
}

void Participant::checkIn()
{
    checkedIn = true;
}
